﻿using System;
using System.Collections.Generic;
using InvestmentIntelligence.DbModel.Models;

namespace InvestmentIntelligence.Data.Repository.Comparers.EntityModelsComparers
{
    public class CurrencyCodeComparer : IEqualityComparer<Currency>
    {
        public bool Equals(Currency x, Currency y)
        {
            if (x == null || y == null) return x == y;
            return string.Equals(x.ISOCode.Trim(), y.ISOCode.Trim(), StringComparison.InvariantCultureIgnoreCase);
        }

        public int GetHashCode(Currency obj)
        {
            return obj.ISOCode == null ? 0 : obj.ISOCode.Trim().ToUpper().GetHashCode();
        }
    }
}